package org.michael.u.brg.i18n.litz;

/**
 * Russian, dumb way. For smart way, see {@link KeyMap} with XML parsing.
 */
public class LitzRu extends LitzXlator {
    public String getVisual(String encoding) {
        int len = encoding.length();
        final StringBuilder sb = new StringBuilder(len * 3);
        boolean register = false;
        for (int i = 0; i < len; i++) {
            char c = encoding.charAt(i);
            switch (c) {
                case 91: // '['
                case 92: // '\\'
                case 93: // ']'
                case 94: // '^'
                case 95: // '_'
                case 96: // '`'
                default:
                    break;

                case 65: // 'A'
                    if (register) {
                        c = '\u042F';
                        register = false;
                    } else {
                        c = '\u0410';
                    }
                    break;

                case 97: // 'a'
                    if (register) {
                        c = '\u044F';
                        register = false;
                    } else {
                        c = '\u0430';
                    }
                    break;

                case 66: // 'B'
                    c = '\u0411';
                    break;

                case 98: // 'b'
                    c = '\u0431';
                    break;

                case 67: // 'C'
                    if (register) {
                        c = '\u0429';
                        register = false;
                    } else {
                        c = '\u0427';
                    }
                    break;

                case 99: // 'c'
                    if (register) {
                        c = '\u0449';
                        register = false;
                    } else {
                        c = '\u0447';
                    }
                    break;

                case 68: // 'D'
                    c = '\u0414';
                    break;

                case 100: // 'd'
                    c = '\u0434';
                    break;

                case 69: // 'E'
                    if (register) {
                        c = '\u042D';
                        register = false;
                    } else {
                        c = '\u0415';
                    }
                    break;

                case 101: // 'e'
                    if (register) {
                        c = '\u044D';
                        register = false;
                    } else {
                        c = '\u0435';
                    }
                    break;

                case 70: // 'F'
                    c = '\u0424';
                    break;

                case 102: // 'f'
                    c = '\u0444';
                    break;

                case 71: // 'G'
                    if (register) {
                        c = '\u0404';
                        register = false;
                    } else {
                        c = '\u0413';
                    }
                    break;

                case 103: // 'g'
                    if (register) {
                        c = '\u0454';
                        register = false;
                    } else {
                        c = '\u0433';
                    }
                    break;

                case 72: // 'H'
                    c = '\u0425';
                    break;

                case 104: // 'h'
                    c = '\u0445';
                    break;

                case 73: // 'I'
                    if (register) {
                        c = '\u042C';
                        register = false;
                    } else {
                        c = '\u0418';
                    }
                    break;

                case 105: // 'i'
                    if (register) {
                        c = '\u044C';
                        register = false;
                    } else {
                        c = '\u0438';
                    }
                    break;

                case 74: // 'J'
                    if (register) {
                        c = '\u042A';
                        register = false;
                    } else {
                        c = '\u0419';
                    }
                    break;

                case 106: // 'j'
                    if (register) {
                        c = '\u044A';
                        register = false;
                    } else {
                        c = '\u0439';
                    }
                    break;

                case 75: // 'K'
                    c = '\u041A';
                    break;

                case 107: // 'k'
                    c = '\u043A';
                    break;

                case 76: // 'L'
                    c = '\u041B';
                    break;

                case 108: // 'l'
                    c = '\u043B';
                    break;

                case 77: // 'M'
                    c = '\u041C';
                    break;

                case 109: // 'm'
                    c = '\u043C';
                    break;

                case 78: // 'N'
                    c = '\u041D';
                    break;

                case 110: // 'n'
                    c = '\u043D';
                    break;

                case 79: // 'O'
                    if (register) {
                        c = '\u0401';
                        register = false;
                    } else {
                        c = '\u041E';
                    }
                    break;

                case 111: // 'o'
                    if (register) {
                        c = '\u0451';
                        register = false;
                    } else {
                        c = '\u043E';
                    }
                    break;

                case 80: // 'P'
                    c = '\u041F';
                    break;

                case 112: // 'p'
                    c = '\u043F';
                    break;

                case 81: // 'Q'
                    c = '\u0426';
                    break;

                case 113: // 'q'
                    c = '\u0446';
                    break;

                case 82: // 'R'
                    c = '\u0420';
                    break;

                case 114: // 'r'
                    c = '\u0440';
                    break;

                case 83: // 'S'
                    c = '\u0421';
                    break;

                case 115: // 's'
                    c = '\u0441';
                    break;

                case 84: // 'T'
                    c = '\u0422';
                    break;

                case 116: // 't'
                    c = '\u0442';
                    break;

                case 85: // 'U'
                    if (register) {
                        c = '\u042E';
                        register = false;
                    } else {
                        c = '\u0423';
                    }
                    break;

                case 117: // 'u'
                    if (register) {
                        c = '\u044E';
                        register = false;
                    } else {
                        c = '\u0443';
                    }
                    break;

                case 86: // 'V'
                    c = '\u0412';
                    break;

                case 118: // 'v'
                    c = '\u0432';
                    break;

                case 87: // 'W'
                    c = '\u0428';
                    break;

                case 119: // 'w'
                    c = '\u0448';
                    break;

                case 88: // 'X'
                case 120: // 'x'
                    register = true;
                    continue;

                case 89: // 'Y'
                    if (register) {
                        c = '\u042A';
                        register = false;
                    } else {
                        c = '\u042B';
                    }
                    break;

                case 121: // 'y'
                    if (register) {
                        c = '\u044A';
                        register = false;
                    } else {
                        c = '\u044B';
                    }
                    break;

                case 90: // 'Z'
                    if (register) {
                        c = '\u0416';
                        register = false;
                    } else {
                        c = '\u0417';
                    }
                    break;

                case 122: // 'z'
                    if (register) {
                        c = '\u0436';
                        register = false;
                    } else {
                        c = '\u0437';
                    }
                    break;
            }
            sb.append(c);
        }

        return sb.toString();
    }

    public String getEncoding(String visual) {
        return "NOT IMPLEMENTED";
    }

    public String getName() {
        return "Russian/Ukrainian";
    }
}
